#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve()
{
    int n;
    string s;
    cin >> n >> s;
    int i = 0;
    int flag1 = 0;
    int flag2 = 0;
    for (i = 0; i < n; i++)
    {
        if (s[i] == 's' && flag1 == 2)
            flag1++;
        if (s[i] == 'f' && flag1 == 1)
            flag1++;
        if (s[i] == 'd' && flag1 == 0)
            flag1++;
        if (s[i] == 'S' && flag2 == 2)
            flag2++;
        if (s[i] == 'F' && flag2 == 1)
            flag2++;
        if (s[i] == 'D' && flag2 == 0)
            flag2++;
    }
    if (flag2 == 3)
        cout << "1 ";
    else
        cout << "0 ";
    if (flag1 == 3)
        cout << "1\n";
    else
        cout << "0\n";
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
